home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Maclife 32
/
MACLIFE32.ISO.7z
/
MACLIFE32.ISO
/
MACLIFE連載
/
DIGITAL DRUG PARADISE
/
HTML
/
WAVMOJ.java
< prev
next >
Wrap
Text File
|
1996-11-14
|
6KB
|
143 lines
import java.awt.*;
import java.io.*;
import java.lang.*;
import java.util.*;
public class WAVMOJ extends java.applet.Applet implements Runnable{
Thread anim;
String s[];
String param;
int mojisize;
int xa=0;
int textwidth=0;
int count=0;
int maxmsg;
char aska[];
float f[];
int maxArray=(int)(Math.PI*10*2);
Color color;
Font font;
FontMetrics fm;
Image imgbf;
Graphics grf;
Dimension d;
public void init(){
d=size();
xa = d.width;
imgbf=createImage(d.width,d.height);
grf=imgbf.getGraphics();
f=new float[maxArray];
double x=3.1;
for(int i=0; i< maxArray ; i++){
f[i]=(float)Math.sin(x);
x -=0.1;
}
param=getParameter("mojisize");
mojisize=(param != null)?Integer.parseInt(param):24;
param=getParameter("msgsu");
maxmsg=(param != null)?Integer.parseInt(param):1;
s=new String[maxmsg];
int j=0;
do{
param=getParameter("message"+(j+1));
if(param != null){
s[j]=new String(param);
}else{
if(param == null){
s[j]="Welcome! Welcome";
}
maxmsg=j+1;
}
}while(param != null && ++j != maxmsg);
}
public void paint(Graphics g){
grf.setColor(Color.black);
grf.fillRect(0,0,d.width,d.height);
int widtt=d.height-3;
for(int i=0; i< s[count-1].length(); i++){
int xm=(int)(Math.random()*10+15*i);
int xc=fm.charWidth(s[count-1].length());
int red=(int)(Math.random()*256);
int green=(int)(Math.random()*256);
int blue=(int)(Math.random()*256);
color=new Color(red,green,blue);
grf.setColor(color);
int uku=0;
int yy;
if(xa+xc<d.width){
if(d.width-xa-i>=0){
uku=(d.width-xa-i)%maxArray;
}else{
uku=0;
}
}
yy=(int)(f[uku]*widtt*0.3);
grf.drawChars(aska,i,1,xa+xm+xc,d.height/2+yy);
}
g.drawImage(imgbf,0,0,d.width,d.height,this);
}
public void start(){
anim=new Thread(this);
anim.start();
}
public void setxa(){
xa=xa-3;
if(xa <- textwidth){
xa=d.width;
}
}
public void run(){
while(true){
preset();
try{
Thread.sleep(100);
}catch(InterruptedException e){};
setxa();
repaint();
}
}
public void update(Graphics g){
paint(g);
}
public void preset(){
font=new Font("Helvetica",Font.PLAIN,mojisize);
grf.setFont(font);
if(xa == d.width){
count++;
if(count > maxmsg){
count=1;
}
}
aska=new char[s[count-1].length()];
s[count-1].getChars(0,s[count-1].length(),aska,0);
fm=grf.getFontMetrics();
textwidth=fm.stringWidth(s[count-1]+"");
}
public void stop(){
if(anim != null){
anim.stop();
anim=null;
}
}
}